home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / LZW.H < prev    next >
C/C++ Source or Header  |  1996-12-23  |  2KB  |  60 lines

  1. #ifndef _LZW_H
  2. #define _LZW_H
  3.  
  4. #ifndef _USOCK_H
  5. #include "usock.h"
  6. #endif
  7.  
  8. /* a string entry */
  9. struct zentry {
  10.     int16 code;    /* codeword of the prefix string */
  11.     char data;    /* character to add to the prefix string */
  12. };
  13. struct zfast {        /* fast version of string entry */
  14.     int16 owncode;    /* own codeword */
  15.     int16 code;    /* codeword of prefix string */
  16.     char data;    /* character to add to prefix string */
  17. };
  18. #define ZCC        256    /* clear code table codeword */
  19. #define ZFLUSH        257    /* codeword that signals a break in coding */
  20.  
  21. struct lzw {
  22.     int16 codebits;        /* significant bits in each codeword */
  23.     int maxbits;        /* maximum number of bits per codeword */
  24. #define LZWBITS        9    /* initial number of bits in each codeword */
  25.     int32 prefix;        /* last processed codeword */
  26.     char mode;        /* Compact or fast compression mode */
  27. #define LZWCOMPACT    0
  28. #define LZWFAST        1
  29.     union {
  30.         struct zentry **tbl;    /* compact table */
  31. #define LZWBLK        130        /* size of entry arrays to allocate */
  32.         struct mbuf **bpp;    /* mbuf version of table */
  33. #define ZHASH        256    /* hash table size */
  34.         void *p;    /* generic table pointer */
  35.     } tu;            /* table of entries */
  36.     int nextbit;        /* next bit to process in code stream */
  37.     int version;        /* version number of sender */
  38. #define ZVERSION    3    /* version number */
  39.     int32 cnt;        /* count of processed bytes */
  40.     int32 code;        /* temporary storage for coding in progress */
  41.     int32 next;        /* next code to be added to the table */
  42.     int flushbit;        /* next bit of the ZFLUSH codeword to send */
  43.     /* the following is used by the decoder only */
  44.     struct mbuf *buf;    /* decoded buffer */
  45. };
  46. #define NULLLZW (struct lzw *)0
  47.  
  48. extern int Lzwmode;
  49. extern int16 Lzwbits;
  50.  
  51. struct usock;
  52.  
  53. void lzwencode (int s,char c);
  54. void lzwinit (int s,int bits,int mode);
  55. void lzwfree (struct usock *up);
  56. void lzwflush (struct usock *up);
  57. int lzwdecode (struct usock *up);
  58.  
  59. #endif  /* _LZW_H */
  60.